<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>监控埋点SDK</title>
  </head>
  <body>
    <div class="container">
      <div class="content">
        <input type="button" value="抛出error" onclick="errorClick()" />
        <input
          type="button"
          value="抛出Promise error"
          onclick="promiseErrorClick()" />
        <input type="button" value="ajax请求成功" onclick="ajaxSuccess()" />
        <input type="button" value="ajax请求失败" onclick="ajaxError()" />
      </div>
    </div>

    <script>
      function errorClick() {
        throw new Error('error')
      }

      function promiseErrorClick() {
        new Promise((resolve, reject) => {
          reject('promise error')
        })
      }

      function ajaxSuccess() {
        const xhr = new XMLHttpRequest()
        xhr.open('GET', '/success', true)
        xhr.responseType = 'json'
        xhr.onload = () => {
          console.log(xhr.response)
        }
        xhr.send()
      }

      function ajaxError() {
        const xhr = new XMLHttpRequest()
        xhr.open('POST', '/error', true)
        xhr.responseType = 'json'
        xhr.onerror = e => {
          console.log(e)
        }
        xhr.send('name=lixuan')
      }
    </script>
    <!-- 资源加载异常 -->
    <!-- <script defer src="../someError.js"></script> -->
  </body>
</html>
